Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync prefs redo issue 6504 #3988

Merged
merged 5 commits into from
Nov 25, 2019
Merged

Conversation

AlexeyBarabash
Copy link
Contributor

@AlexeyBarabash AlexeyBarabash commented Nov 13, 2019

Fixes brave/brave-browser#6504

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Verified that these changes build without errors on
    • Android
    • iOS
    • Linux
    • macOS
    • Windows
  • Verified that these changes pass automated tests (unit, browser, security tests) on
    • iOS
    • Linux
    • macOS
    • Windows
      Seeing not related with PR fails at:
13 tests failed:
    BraveRewardsBrowserTest.AutoContribution (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2052)
    BraveRewardsBrowserTest.ContributionWithLowAmount (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2218)
    BraveRewardsBrowserTest.InsufficientNotificationForInsufficientAmount (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2533)
    BraveRewardsBrowserTest.InsufficientNotificationForVerifiedInsufficientAmount (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2568)
    BraveRewardsBrowserTest.MultipleRecurringOverBudgetAndPartialAutoContribution (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2964)
    BraveRewardsBrowserTest.PendingContributionTip (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2415)
    BraveRewardsBrowserTest.RecurringAndPartialAutoContribution (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2917)
    BraveRewardsBrowserTest.RecurringTipForUnverifiedPublisher (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2197)
    BraveRewardsBrowserTest.RecurringTipForVerifiedPublisher (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2176)
    BraveRewardsBrowserTest.TipConnectedPublisherAnonAndConnected (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2792)
    BraveRewardsBrowserTest.TipNonIntegralAmount (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2876)
    BraveRewardsBrowserTest.TipUnverifiedPublisher (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2156)
    BraveRewardsBrowserTest.TipVerifiedPublisher (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2137)
1 test timed out:
    BraveRewardsBrowserTest.ProcessPendingContributions (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2615)

Test Plan:

Please see the next message

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@AlexeyBarabash
Copy link
Contributor Author

AlexeyBarabash commented Nov 14, 2019

Steps to check the issue in different situation

I. Check how works reset with Leave Sync Chain button

  1. Create sync chain of 2 devices, deviceA and deviceB
  2. Press Leave Sync Chain button on deviceA
  3. Ensure chain have been reset on deviceA, but there is deviceB on deviceB itself.
    In other words, on deviceA Sync setup initial page is displayed; and on deviceB may appear a dialog of Choose device type to connect to - because deviceB has only one device in it's chain, deviceB itself - in this case close the dialog with cross, or in version without cross press Computer and then Cancel to see the list of devices.

II. Check how works reset over pressing cross near this device

  1. Create sync chain of 2 devices, deviceA and deviceB
  2. Press cross link near this device
  3. Ensure chain have been reset on deviceA, but there is deviceB on deviceB itself

III. Check how works Reset over pressing cross near opposite device

  1. Create sync chain of 2 devices, deviceA and deviceB
  2. From deviceB press cross link near deviceA,
  3. Ensure chain have been reset on deviceA only

IV. Check the original STR from brave/brave-browser#6504 becomes not applicable

  1. Prepare clear profiles deviceA and deviceB
  2. Launch profile A, create new sync chain, ensure sync code is shown, but don't copy the code. Close deviceA.
  3. Launch profile B, create new sync chain, copy sync code, don't close.
  4. Launch profile A - it should show none or one device and View Sync Code button is available, as sync is configured, so STR from the original issue are not available.

V. Check this PR build works with from old version by STR at brave-browser#6504

  1. Prepare clear profiles deviceA and deviceB
  2. Launch Stable version 1.0 on profileA. Create new sync chain, ensure sync code is shown, but don't copy the code. Close deviceA.
  3. Launch profile B, create new sync chain, copy sync code, don't close.
  4. Launch this PR build on profile A - it will show there is one device in chain (and should ask to connect other devices).

VI. Check we send bookmarks as soon as sync is enabled even if there are one device in chain

  1. Prepare clear profile deviceA, containing bookmarks A1.com and A2.com
  2. Start a new sync chain
  3. Open chrome://inspect/#extensions and check for Brave Sync logs.
  4. Ensure you can see "send-sync-records" category_name="BOOKMARKS" records=...
This below will go to the a separate PR for issue https://github.com/brave/brave-browser/issues/3628

Check how works reset with Leave Sync Chain button when the device is offline

  1. Create sync chain of 2 devices, deviceA and deviceB
  2. Turn off the internet connection on deviceA
  3. Press Leave Sync Chain button on deviceA
  4. Ensure chain have been reset on deviceA, but there deviceB still have deviceA in list
  5. Close browser deviceA; turn on the internet conenction, launch browser of deviceA - ensure there are no sync chain on deviceA

@AlexeyBarabash
Copy link
Contributor Author

Created an issue for UI changes: brave/brave-browser#6941 .

@AlexeyBarabash
Copy link
Contributor Author

Marked it ready for review to trigger the CI.
Two commits of this PR should be removed / replaced before merge

@AlexeyBarabash
Copy link
Contributor Author

rebased due to Version mismatch between brave-browser and brave-core in package.json CI failure

components/brave_sync/brave_profile_sync_service_impl.cc Outdated Show resolved Hide resolved
components/brave_sync/brave_profile_sync_service_impl.cc Outdated Show resolved Hide resolved
device_name, object_id, SyncRecord::Action::A_DELETE, device_id);
base::PostDelayedTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&BraveProfileSyncServiceImpl::OnResolvedPreferencesWrp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for? I thought FetchDevices will also trigger OnResolvedPreferences after we send delete this device record and then we see this device get deleted, then we reset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the case when we want to reset the sync but internet connection is offline.
When the internet is offline, FetchDevices will get empty result, and we will not be able to call ResetSyncInternal()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we can simplify it by making sure DELETE device record is sent by OnRecordsSent and then we can call ResetSyncInternal() without involving OnResolvedPreferences

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This delayed task doesn't really solve this situation

IV. Check how works reset with Leave Sync Chain button when the device is offline

1. Create sync chain of 2 devices, deviceA and deviceB
2. Turn off the internet connection on deviceA
3. Press Leave Sync Chain button on deviceA
4. Ensure chain have been reset on deviceA, but there deviceB still have deviceA in list
5. Close browser deviceA; turn on the internet conenction, launch browser of deviceA - ensure there are no sync chain on deviceA

device B still doesn't get delete record from A

Here are what we can do

  1. If we want to make sure device B gets DELETE A record, we need to block A from Reset until device A sends the record (which means device A get online)
  2. Or we can leverage OnRecordsSent as I mentioned in https://github.com/brave/brave-core/pull/3988/files#r348770951
    It will get called no matter success or failure, then we call ResetSyncInternal() (failure will have empty records)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the case when internet connection is off there could not be a perfect solution, because we cannot send device DELETE record.

The option with delayed task gives two good points:

  1. If internet connection is on, then the device is able to send DELETE record, so it informs all other. No disadvantages here.
  2. If internet connection is off, then the device is able to make a proper self-reset. The only disadvantage is - other devices would not be informed and could see zobmie.

Any block of ourselves until get device DELETE record confirmation, makes sync to be under pending reset for an unknown time.

As for now, when the internet connection is off, sending DEVICE delete record will never reach to AWS, because we do resend for bookmarks only.

We can leverage OnRecordsSent and do there a cancellation of delayed task if we see device DELETE with our device_id. @darkdh what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don’t need delayed task if we use OnRecordsSent because when offline or any failed to send, it will get called with EMPTY records to indicate failure.

Copy link
Contributor Author

@AlexeyBarabash AlexeyBarabash Nov 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per Slack discussion, the case of reset when the device is offline will be done as separate issue (brave/brave-browser#3628) + separate PR after this PR will be merged.

components/brave_sync/brave_profile_sync_service_impl.cc Outdated Show resolved Hide resolved
components/brave_sync/brave_sync_service_unittest.cc Outdated Show resolved Hide resolved
@AlexeyBarabash AlexeyBarabash force-pushed the sync_prefs_redo_issue_6504 branch 3 times, most recently from 50f7596 to 6f8b187 Compare November 20, 2019 11:54
@AlexeyBarabash
Copy link
Contributor Author

@darkdh addressed all comments, could you please look again?

Copy link
Member

@darkdh darkdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some UI issues like

  1. Right after sync chain is created, copy sync code/scan QR code dialog dismiss immediately and I have to click
    Screen Shot 2019-11-20 at 15 23 45 in order to add second device
  2. copy sync code/scan QR code can not be dismissed when there is only one device in sync chain( only achievable by close the tab or refresh the brave://sync), otherwise, it leads to Reset

Both can be addressed by brave/brave-browser#6941 (comment)

device_name, object_id, SyncRecord::Action::A_DELETE, device_id);
base::PostDelayedTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&BraveProfileSyncServiceImpl::OnResolvedPreferencesWrp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This delayed task doesn't really solve this situation

IV. Check how works reset with Leave Sync Chain button when the device is offline

1. Create sync chain of 2 devices, deviceA and deviceB
2. Turn off the internet connection on deviceA
3. Press Leave Sync Chain button on deviceA
4. Ensure chain have been reset on deviceA, but there deviceB still have deviceA in list
5. Close browser deviceA; turn on the internet conenction, launch browser of deviceA - ensure there are no sync chain on deviceA

device B still doesn't get delete record from A

Here are what we can do

  1. If we want to make sure device B gets DELETE A record, we need to block A from Reset until device A sends the record (which means device A get online)
  2. Or we can leverage OnRecordsSent as I mentioned in https://github.com/brave/brave-core/pull/3988/files#r348770951
    It will get called no matter success or failure, then we call ResetSyncInternal() (failure will have empty records)

@AlexeyBarabash AlexeyBarabash force-pushed the sync_prefs_redo_issue_6504 branch 3 times, most recently from 16f6653 to 209f9ce Compare November 22, 2019 11:12
@AlexeyBarabash
Copy link
Contributor Author

Squashed all fix-meaning commits

@AlexeyBarabash
Copy link
Contributor Author

CI failed with two errors:

19:51:06  ERROR at //services/media_session/public/mojom/BUILD.gn:27:25: Assignment had no effect.
19:51:06    export_header_blink = "third_party/blink/public/platform/web_common.h"
19:51:06                          ^-----------------------------------------------
19:51:06  You set the variable "export_header_blink" here and it was unused before it went
19:51:06  out of scope.
19:51:06  See //content/public/browser/BUILD.gn:408:5: which caused the file to be included.
19:51:06      "//services/media_session/public/mojom",
19:51:06      ^--------------------------------------

and an unclear at npm run create_dist -- Release --channel=nightly --official_build=true

IOError: [Errno 2] No such file or directory: 'Brave Browser Nightly.app/Contents/Frameworks/Brave Browser Nightly Framework.framework/Versions/78.1.3.24/Brave Browser Nightly Framework'

both are not related with PR, doing last attempt rebase.

@AlexeyBarabash
Copy link
Contributor Author

CI failed with only error


13:28:12  ERROR at //services/media_session/public/mojom/BUILD.gn:27:25: Assignment had no effect.
13:28:12    export_header_blink = "third_party/blink/public/platform/web_common.h"
13:28:12                          ^-----------------------------------------------
13:28:12  You set the variable "export_header_blink" here and it was unused before it went
13:28:12  out of scope.
13:28:12  See //content/public/browser/BUILD.gn:408:5: which caused the file to be included.
13:28:12      "//services/media_session/public/mojom",
13:28:12      ^--------------------------------------

for npm run build -- Release --channel=nightly --official_build=true --target_os=ios

@kjozwiak
Copy link
Member

@AlexeyBarabash should this PR be in 1.3.x. Currently doesn't have an associated milestone.

@AlexeyBarabash AlexeyBarabash added this to the 1.3.x - Dev milestone Dec 17, 2019
@AlexeyBarabash
Copy link
Contributor Author

@kjozwiak yes, it should be in 1.3.x, as it was merged when master was 1.3.x . Added the milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sync cannot enable chain sometimes
4 participants